#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/wait.h>

int main()
{

    pid_t id = fork();
    if(id < 0)
    {
        perror("fork");
        exit(1);
    }
    if(id == 0)
    {
        //child
        int cnt = 4;
        while(cnt--)
        {
            printf("i am child pid = %d ppid = %d\n",getpid(),getppid());
            sleep(1);
        }
        return 0;
    }
    //parent
    pid_t rid = waitpid(-1,NULL,0);
    printf("i am father pid = %d ppid = %d\n",getpid(),getppid());
    return 0;

}
